import 'package:ddstore/dd_notifier.dart';
import 'package:ddstore/widgets/dd_future_builder.dart';
import 'package:flutter/material.dart';

class DDPageController<T> {
  static const _reloadAction = "_reloadAction";
  static const _updateData = '_updateData';
  List<T>? _items;
  DDNotifier _notifier = DDNotifier();

  List<T>? get items {
    return _items;
  }

  Future reload({
    DDFutureStatus reloadStartStatus = DDFutureStatus.loading,
    bool scrollTop = false,
  }) {
    return _notifier.dispatch(_reloadAction, type: DDActionFutureType.wait, namedArguments: {
      #reloadStartStatus: reloadStartStatus,
      #scrollTop: scrollTop,
    });
  }

  void updateData(List<T>? data) {
    _notifier.dispatch(_updateData, positionalArguments: [data]);
  }
}

class DDPaginationBuilder extends StatefulWidget {
  const DDPaginationBuilder({super.key});

  @override
  State<DDPaginationBuilder> createState() => _DDPaginationBuilderState();
}

class _DDPaginationBuilderState extends State<DDPaginationBuilder> {
  @override
  Widget build(BuildContext context) {
    return Container();
  }
}
